package com.jinhua.huaojcodesandbox.unsafe;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class RunFileError {
    public static void main(String[] args) throws IOException, InterruptedException {
        String userDir = System.getProperty("user.dir");
        String filePath = userDir + File.separator + "src/main/resources/木马.bat";
        Process exec = Runtime.getRuntime().exec(filePath);
        exec.waitFor();

//            如果正常退出就从process的inputStream中获取输出信息
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream(), StandardCharsets.UTF_8));

        String compileOutputLine;
//                使用buffereReader逐行读取控制台输出的信息
        while ((compileOutputLine = bufferedReader.readLine()) != null) {

            System.out.println(compileOutputLine);
        }

    }
}
